package com.kizuki.net;

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) {
        Socket client = null;
        DataInputStream dis = null;
        DataOutputStream dos = null;

        try {
            client = new Socket("127.0.0.1", 4453);
            dis = new DataInputStream(client.getInputStream());
            dos = new DataOutputStream(client.getOutputStream());

            String disStr = null;
            String dosStr = null;
            Scanner scanner = new Scanner(System.in);
            while (true) {
                dosStr = scanner.next();
                dos.writeUTF(dosStr);
                disStr = dis.readUTF();
                System.out.println("服务器说：" + disStr);
            }
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            try {
                dis.close();
                dos.close();
                client.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
